package com.chuangsi.project.system.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 文件表
 * </p>
 *
 * @author
 * @since 2022-11-24
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "File对象", description = "文件表")
@TableName("t_file_path")
public class File extends Model<File> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "文件id")
    @TableId(value = "file_id", type = IdType.ASSIGN_UUID)
    @NotEmpty(message = "文件id不能为空")
    @Size(max = 32, message = "文件id长度过长")
    private String fileId;

    @ApiModelProperty(value = "源id")
    @NotEmpty(message = "源id不能为空")
    @Size(max = 32, message = "源id长度过长")
    private String sourceId;

    @ApiModelProperty(value = "类型（1.项目附件 2.专业）")
    @NotEmpty(message = "类型（1.项目附件 2.专业）不能为空")
    @Size(max = 50, message = "类型（1.项目附件 2.专业）长度过长")
    private String type;

    @ApiModelProperty(value = "文件地址")
    @NotEmpty(message = "文件地址不能为空")
    @Size(max = 256, message = "文件地址长度过长")
    private String uri;

    @ApiModelProperty(value = "文件名称")
    @Size(max = 128, message = "文件名称长度过长")
    private String fileName;

    @ApiModelProperty(value = "文件类型（1.文件，2.图片，3视频）")
    @Size(max = 1, message = "文件类型（1.文件，2.图片，3视频）长度过长")
    private String fileType;

    @ApiModelProperty(value = "上传文件人id")
    @Size(max = 32, message = "上传文件人id长度过长")
    private String handleId;

    @ApiModelProperty(value = "备用id")
    @Size(max = 32, message = "备用id长度过长")
    private String backupId;


    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @NotNull(message = "创建时间不能为空")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @NotNull(message = "修改时间不能为空")
    private LocalDateTime updateTime;


    @Override
    public Serializable pkVal() {
        return this.fileId;
    }

}
